package com.wyx.rtddels.controller;

import com.wyx.rtddels.service.RtdTagService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author WYX
 * @date 2024/8/20
 * @Description
 */
@RestController
@RequestMapping("dels")
public class DelController  {


    @Resource
    RtdTagService rtdTagService;

    /**
     * 获取token
     */
    @GetMapping("tset")
    public void test(){
        rtdTagService.getToken();
    }


    /**
     * 最终结果测试写入和写出文件地址
     * @return
     */
    @GetMapping("testDels")
    public boolean trySendAndWriter(){
        boolean flag=rtdTagService.trySend();
        return flag;
    }


    @GetMapping("OnlyDels")
    public boolean tryDels(){
        boolean flag=rtdTagService.del();
        return flag;
    }

    /**
     * 导入文件
     * @param request
     * @param multipartFile
     */
    @GetMapping("getFiles")
    public void getFiles(HttpServletRequest request, MultipartFile multipartFile){

        try {
            int read = multipartFile.getInputStream().read();
            System.out.println(read);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
